package inventario;

import conexion.CConexion;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class CInvare100 extends CConexion {

    String compania = null;

    public CInvare100() {
        super();
        this.compania = login.getCompaniaActual();
    }

    public ResultSet areas() throws SQLException {
        String sqlArea = "SELECT distinct(are100desc) FROM invare100 where are100nocia = '" + compania + "' order by are100desc";
        Statement stncArea = this.getConexion().createStatement();
        ResultSet rsArea = stncArea.executeQuery(sqlArea);
        return rsArea;
    }

    public String codigoArea(String descripcion) throws SQLException {
        String sqlCodigo = "SELECT are100cdgo from invare100 where are100nocia = '" + compania + "' and are100desc = '" + descripcion + "'";
        Statement stncCodigo = this.getConexion().createStatement();
        ResultSet rsCodigo = stncCodigo.executeQuery(sqlCodigo);
        rsCodigo.next();
        String codigo = rsCodigo.getString("are100cdgo");
        rsCodigo.close();
        stncCodigo.close();
        return codigo;
    }

    public String descripcionArea(String codigo) throws SQLException {
        String sqlDescripcion = "SELECT are100desc from invare100 where are100nocia = '" + compania + "' and are100cdgo = '" + codigo + "'";
        Statement stncDescripcion = this.getConexion().createStatement();
        ResultSet rsDescripcion = stncDescripcion.executeQuery(sqlDescripcion);
        rsDescripcion.next();
        String nomb = rsDescripcion.getString("are100desc");
        rsDescripcion.close();
        stncDescripcion.close();
        return nomb;
    }
}
